package gamePack.entities;

import gamePack.Controller;
import gamePack.Game;
import gamePack.Physics;
import gamePack.gfx.Animation;
import gamePack.gfx.ImageManager;

import java.awt.Graphics;
import java.awt.Rectangle;

public class Bullet extends GameObject implements EntityA {

	private Physics fisica;
	private Game game;

	private Animation bulletAnim;
	private ImageManager im;
	private Controller control;

	private final int MISSILE_SPEED = 7;

	public Bullet(int x, int y, Game game, ImageManager im, Controller control,
			Physics fisica) {
		super(x, y);
		this.fisica = fisica;
		this.game = game;
		this.im = im;
		bulletAnim = new Animation(im.getBullet(), 500);
		this.control = control;
	}

	public void tick() {

		y = y - MISSILE_SPEED;
		if (y <= -20)
			control.removeEntity(this);
		else if (fisica.Collision(this, game.getEntB())) {
			game.aBorrarEntA(this);
		}
		
	}

	public void render(Graphics g) {
		bulletAnim.render(g, x, y, game.getTileSize(), game.getTileSize());
	}

	public Rectangle getBounds() {
		return new Rectangle(x, y, 32, 32);
	}

	public int getY() {
		return y;
	}

	public int getX() {
		return x;
	}

}